package com.photoeditor.demo.ui.widget.image.brush;

import android.content.Context;
import android.util.AttributeSet;

import com.android.gpuimage.GPUImageFilter;
import com.android.gpuimage.GPUImageFilterGroup;
import com.android.gpuimage.WhitenFilter;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by winn on 17/8/15.
 */

public class WhitenBrushView extends BrushView {

    private static final int EFFECT_PERCENTAGE = 60;

    public WhitenBrushView(Context context) {
        super(context);
    }

    public WhitenBrushView(Context context, AttributeSet attributeSet) {
        super(context, attributeSet);
        setPaintStyle(PAINT_STYLE_SOFT);
    }

    @Override
    protected GPUImageFilter createFilter() {
        WhitenFilter whitenFilter = new WhitenFilter();

        GPUImageFilterGroup filterGroup = new GPUImageFilterGroup();
        filterGroup.addFilter(whitenFilter);
        return filterGroup;
    }

    @Override
    protected List<GPUImageFilter> createFilterList() {
        List<GPUImageFilter> filters = new ArrayList<>();

        WhitenFilter whitenFilter = new WhitenFilter();

        GPUImageFilterGroup filterGroup = new GPUImageFilterGroup();
        filterGroup.addFilter(whitenFilter);

        filters.add(filterGroup);

        return filters;
    }

    protected float range(final int percentage, final float start, final float end) {
        return (end - start) * percentage / 100.0f + start;
    }
}
